package com.ai.controller.made;

import com.ai.annotation.EnterPathParamLog;
import com.ai.common.exception.JeecgBootException;
import com.ai.entity.made.Pictures;
import com.ai.service.made.IPicturesService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author chen
 * @since 2023-03-28 11:12:30
 */
@RestController
@RequestMapping("/pictures")
public class PicturesController {

    @Resource
    IPicturesService picturesService;

    @ApiOperation("获取小图片")
    @PostMapping("getPictures")
    @EnterPathParamLog
    public List<Pictures> getPictures(@RequestBody Pictures pictures) {

        if (!StringUtils.hasText(pictures.getSlabNum())) throw new JeecgBootException("板坯号不能违空");
        if (pictures.getSurface() == null || pictures.getSurface() == 0)
            throw new JeecgBootException("请选择上表面或者下表面");

        List<Pictures> pictureList = picturesService.list(new QueryWrapper<Pictures>().eq("slab_num", pictures.getSlabNum()).eq("surface", pictures.getSurface()));
        return pictureList;
    }
}
